package com.mimosa.common.system.log;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mimosa.common.dao.HibernateDao;
import com.mimosa.common.service.CommonService;
import com.mimosa.util.config.Page;

/**
 * 日志service
 * 
 * @author yunjum
 * 
 */
@Service
@Transactional
public class LogService extends CommonService<TLog, String> {
	@Autowired
	private TLogDao logDao;

	/**
	 * 获取日志。
	 * 
	 * @param page
	 * @param criterions
	 * @return
	 */
	public Page<TLog> getPage(Page<TLog> page) {
		page.setOrder(Page.DESC);
		page.setOrderBy("createTime");
		return this.logDao.findPage(page);
	}

	/**
	 * 删除日志根据id
	 * 
	 * @param logId
	 */
	public void deleteLog(String logId) {
		this.logDao.delete(logId);
	}

	/**
	 * 删除全部日志
	 * 
	 * @return
	 */
	public int deleteLog() {
		String hql = "delete from Log";
		return this.logDao.batchExecute(hql);
	}

	@Override
	protected HibernateDao<TLog, String> getHibernateDao() {
		return this.logDao;
	}
}
